//
//  SYRequestAPI+YueJuan.m
//  SanYiTeaching
//
//  Created by 郑浩然 on 2019/6/5.
//  Copyright © 2019年 SanYi. All rights reserved.
//


//阅卷---批改--获取试题
NSString *const kSYFYJPiGaiBaseUrl = @"paper/CorrectService.svc/";
//6.8.2    统计 StatisticsService
NSString *const kSYYJTongJiBaseUrl = @"paper/StatisticsService.svc/";

NSString *const kSYYJDingZhengBaseUrl = @"paper/ReviseService.svc/";

NSString *const kSYZYTongJiBaseUrl = @"teach/HomeWordService.svc/";


#import "SYRequestAPI+YueJuan.h"
#import "SYKaoPingZYModel.h"

@implementation SYRequestAPI (YueJuan)
//阅卷批改--获取试题
+ (void)yj_requestCorrectServicePullQuestionsObj:(id)obj
                                         success:(void(^)(NSMutableArray *dataListArr))success
                                            fail:(FailBlock)fail
{
    
    
    
    
    
//    NSString *bundlePath = [[NSBundle mainBundle] pathForResource:@"Info" ofType:@"plist"];
//    NSMutableDictionary *infoDict = [NSMutableDictionary dictionaryWithContentsOfFile:bundlePath];
//    NSDictionary *dict = infoDict[@"details"];
//    NSString  *htmlStr = dict[@"key"];
//    NSString  *right = dict[@"value"];
//    NSMutableArray *dataArr = [[NSMutableArray alloc] init];
//    for (NSInteger i = 0; i < 10; i++) {
//        SYYueJuanShiTiModel *yjstModel = [[SYYueJuanShiTiModel alloc] init];
//        yjstModel.isPiGai = NO;
//        yjstModel.fenSu = @"4";
//        yjstModel.questionContent = htmlStr;
//        yjstModel.rightAnswerContent = right;
//        yjstModel.studentAnswer = @"Student/刘子涵/201905231440477839-692.png";
//        yjstModel.templateHeight = @"608";
//        yjstModel.templateWidth = @"875";
//        yjstModel.questionScore = @"4";
//        yjstModel.areaWidth = @"57";
//        yjstModel.studentName = @"发叉大大";
//        yjstModel.dataWrongReasonsArr = [NSMutableArray array];
//        NSArray *dataResArr = @[@"熟练度",@"标签"];
//        for (NSString *titleStr in dataResArr) {
//            SYAlterViewModel *alterModel = [[SYAlterViewModel alloc] init];
//            alterModel.biqianid = @"22";
//            alterModel.name = titleStr;
//            [yjstModel.dataWrongReasonsArr addObject:alterModel];
//        }
//
//        [dataArr addObject:yjstModel];
//    }
//
//
//    if (success) {
//        success(dataArr);
//    }
    
    

    NSString *url = SYStringWithPickFormat(kSYFYJPiGaiBaseUrl, @"pullQuestions");

    NSDictionary *dict = @{

                           };

    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {

        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *listArr = responseObject[@"data"];
        for ( NSDictionary *dict in listArr) {
            SYYueJuanShiTiModel *yjstModel = [SYYueJuanShiTiModel yy_modelWithDictionary:dict];
            yjstModel.isPiGai = NO;
            yjstModel.fenSu = @"4";
            [dataArr addObject:yjstModel];

            yjstModel.dataWrongReasonsArr = [NSMutableArray array];
            NSArray *dataReasonsArr = dict[@"dataWrongReasons"];
            for (NSDictionary *resDict in dataReasonsArr) {
                SYAlterViewModel *alterModel = [SYAlterViewModel yy_modelWithDictionary:resDict];
                [yjstModel.dataWrongReasonsArr addObject:alterModel];
            }
//            NSArray *dataResArr = @[@"熟练度",@"标签"];
//            for (NSString *titleStr in dataResArr) {
//                SYAlterViewModel *alterModel = [[SYAlterViewModel alloc] init];
//                alterModel.biqianid = @"22";
//                alterModel.name = titleStr;
//                [yjstModel.dataWrongReasonsArr addObject:alterModel];
//            }

        }
        if (success) {
            success(dataArr);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

//6.8.1.3    退回试题
+ (void)yj_requestCorrectServiceSendBackQuestionIds:(NSString *)questionIds
                                            success:(void(^)(BOOL isSuccess))success
                                               fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFYJPiGaiBaseUrl, @"SendBackQuestion");
    
    NSDictionary *dict = @{
                           @"questionIds":questionIds
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//批改试题
+ (void)yj_requestcorrectServiceCorrectQuestionAnswerId:(NSString *)answerId
                                                isRight:(NSString *)isRight
                                                  score:(NSString *)score
                                    studentAnswerFileId:(NSString *)studentAnswerFileId
                                        answerImagePath:(NSString *)answerImagePath
                                         wrongReasonIds:(NSString *)wrongReasonIds
                                      isCorrectQuestion:(BOOL)question
                                                success:(void(^)(BOOL isSuccess))success
                                                   fail:(FailBlock)fail
{
    NSString *url = nil;
    if (question == NO) {//已批改
        url = SYStringWithPickFormat(kSYFYJPiGaiBaseUrl, @"CorrectQuestion");
    } else {//重批
        url = SYStringWithPickFormat(kSYFYJPiGaiBaseUrl, @"ReCorrectQuestion");
    }
    
    
    NSDictionary *dict = @{
                           @"answerId":answerId,
                           @"isRight":isRight,
                           @"score":score,
                           @"studentAnswerFileId":studentAnswerFileId,
                           @"answerImagePath":answerImagePath,
                           @"wrongReasonIds":wrongReasonIds
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

+ (void)yj_requestCorrectServiceCorrectLogPageIndex:(NSInteger)index
                                           pageSize:(NSInteger)size
                                            success:(void(^)(NSMutableArray *dataListArr))success
                                               fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYFYJPiGaiBaseUrl, @"CorrectLog");
    
    NSDictionary *dict = @{
                           @"pageIndex":SJStringWithFormat(index),
                           @"pageSize":SJStringWithFormat(size),
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        //SYCorrectLogModel
        NSMutableArray *dataArr = [NSMutableArray array];
        NSArray *dataListArr = responseObject[@"data"];
        for (NSDictionary *dict in dataListArr) {
            SYCorrectLogModel *logModel = [SYCorrectLogModel yy_modelWithDictionary:dict];
            [dataArr addObject:logModel];
        }
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//重新批改
+ (void)yj_requestCorrectServiceReCorrectQuestionCorrectId:(NSString *)correctId
                                                     score:(NSString *)score
                                                   isRight:(NSString *)isright
                                           answerImagePath:(NSString *)answerImagePath
                                            wrongReasonIds:(NSString *)wrongReasonIds
                                                   success:(void(^)(BOOL isSuccess))success
                                                      fail:(FailBlock)fail
{
    
    
    NSString *url = nil;
   
    url = SYStringWithPickFormat(kSYFYJPiGaiBaseUrl, @"ReCorrectQuestion");
    
    
    
    NSDictionary *dict = @{
                           @"correctId":correctId,
                           @"score":score,
                           @"isRight":isright,
                           @"answerImagePath":answerImagePath,
                           @"wrongReasonIds":wrongReasonIds
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        if (success) {
            success(YES);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
    
}

+ (void)yj_requestCorrectServiceDetailsInfoAnswerIds:(NSString *)answerIds
                                             success:(void(^)(NSMutableArray *dataListArr))success
                                                fail:(FailBlock)fail
{
    NSString *url = @"paper/CorrectService.svc/GetFeedbackQuestionDetailInfo";
    
    NSDictionary *dict = @{
                           @"answerIds":answerIds
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        NSMutableArray *dataArr = [[NSMutableArray alloc] init];
        NSArray *data = responseObject[@"data"];
        NSDictionary *dict = data.firstObject;
        SYYueJuanShiTiModel *yjstModel = [SYYueJuanShiTiModel yy_modelWithDictionary:dict];
        yjstModel.isPiGai = NO;
        yjstModel.fenSu = @"4";
        [dataArr addObject:yjstModel];
        
        yjstModel.dataWrongReasonsArr = [NSMutableArray array];
        NSArray *dataReasonsArr = dict[@"dataWrongReasons"];
        for (NSDictionary *resDict in dataReasonsArr) {
            SYAlterViewModel *alterModel = [SYAlterViewModel yy_modelWithDictionary:resDict];
            [yjstModel.dataWrongReasonsArr addObject:alterModel];
        }
        //                NSArray *dataResArr = @[@"熟练度",@"标签"];
        //                for (NSString *titleStr in dataResArr) {
        //                    SYAlterViewModel *alterModel = [[SYAlterViewModel alloc] init];
        //                    alterModel.biqianid = @"22";
        //                    alterModel.name = titleStr;
        //                    [yjstModel.dataWrongReasonsArr addObject:alterModel];
        //                }
        
        
        if (success) {
            success(dataArr);
        }
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

+ (void)yj_requestCorrectServiceCorrectDetailsId:(NSString *)correctId
                                         success:(void(^)(NSMutableArray *dataListArr))success
                                            fail:(FailBlock)fail
{
    
        NSString *url = SYStringWithPickFormat(kSYFYJPiGaiBaseUrl, @"CorrectDetail");
    
        NSDictionary *dict = @{
                               @"correctId":correctId
                               };
    
        [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
    
            NSMutableArray *dataArr = [[NSMutableArray alloc] init];
            NSDictionary *dict = responseObject[@"data"];
           
            SYYueJuanShiTiModel *yjstModel = [SYYueJuanShiTiModel yy_modelWithDictionary:dict];
            yjstModel.isPiGai = NO;
            yjstModel.fenSu = @"4";
            [dataArr addObject:yjstModel];

            yjstModel.dataWrongReasonsArr = [NSMutableArray array];
            NSArray *dataReasonsArr = dict[@"dataWrongReasons"];
            for (NSDictionary *resDict in dataReasonsArr) {
                SYAlterViewModel *alterModel = [SYAlterViewModel yy_modelWithDictionary:resDict];
                [yjstModel.dataWrongReasonsArr addObject:alterModel];
            }
//                NSArray *dataResArr = @[@"熟练度",@"标签"];
//                for (NSString *titleStr in dataResArr) {
//                    SYAlterViewModel *alterModel = [[SYAlterViewModel alloc] init];
//                    alterModel.biqianid = @"22";
//                    alterModel.name = titleStr;
//                    [yjstModel.dataWrongReasonsArr addObject:alterModel];
//                }
    
            
            if (success) {
                success(dataArr);
            }
        } fail:^(NSError *error) {
            if (error) {
                fail(error);
            }
        }];
}
//统计
+ (void)yj_requestStatisticsServiceExamListPageIndex:(NSInteger)pageIndex
                                            pageSize:(NSInteger)pageSize
                                             success:(void(^)(NSMutableArray *dataListArr))success
                                                fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYYJTongJiBaseUrl, @"ExamList");
    
    NSDictionary *dict = @{
                           @"pageIndex":SJStringWithFormat(pageIndex),
                           @"pageSize":SJStringWithFormat(pageSize),
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        //SYCorrectLogModel
        NSMutableArray *dataArr = [NSMutableArray array];
        NSArray *dataListArr = responseObject[@"data"];
        for (NSDictionary *dict in dataListArr) {
            SYExamListModel *logModel = [SYExamListModel yy_modelWithDictionary:dict];
            [dataArr addObject:logModel];
        }
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//考试信息
+ (void)yj_requestStatisticsServiceEXamInfoTemplateId:(NSString *)templateId
                                              success:(void(^)(NSMutableArray *dataListArr))success
                                                 fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYYJTongJiBaseUrl, @"ExamInfo");
    
    NSDictionary *dict = @{
                           @"templateId":templateId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        //SYCorrectLogModel
        NSMutableArray *dataArr = [NSMutableArray array];
        NSDictionary *dic = responseObject[@"data"];
        SYExamInfoModel *logModel = [SYExamInfoModel yy_modelWithDictionary:dic];
        logModel.dataClassesArr = [NSMutableArray array];
        NSArray *dataClassesArr = dic[@"dataClasses"];//班级
        NSInteger index = 0;
            for (NSDictionary *classesDict in dataClassesArr) {
                SYExamInfoClassesModel *classesModel = [SYExamInfoClassesModel yy_modelWithDictionary:classesDict];
                if (index == 0) {//默认第一个选中
                    classesModel.isSelect = YES;
                } else {
                    classesModel.isSelect = NO;
                }
                index ++;
                classesModel.newisSelect = NO;
                classesModel.dataStudentsArr = [NSMutableArray array];//学生
                NSArray *studentsArr = classesDict[@"dataClassesStudents"];
                    for (NSDictionary *studentsDict in studentsArr) {
                        SYExamInfoStudentsModel *studentsModel = [SYExamInfoStudentsModel yy_modelWithDictionary:studentsDict];
                        studentsModel.isSelect = YES;
                        studentsModel.newisSelect = YES;
                        [classesModel.dataStudentsArr addObject:studentsModel];
                    }
                
                [logModel.dataClassesArr addObject:classesModel];
            }
        [dataArr addObject:logModel];
        
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//按照试题统计
+ (void)yj_requestStatisticsServiceByQuestionClassIds:(NSString *)classids
                                           studentIds:(NSString *)studentIds
                                           templateId:(NSString *)templateId
                                    kaoshiOrDingzheng:(BOOL)isksordz
                                              success:(void(^)(NSMutableArray *dataListArr))success
                                                 fail:(FailBlock)fail
{
    NSString *url = nil;
    if (isksordz== YES) {//考试统计
        url = SYStringWithPickFormat(kSYYJTongJiBaseUrl, @"StatisticsByQuestion");
       
        
    } else {//订正统计
        url = SYStringWithPickFormat(kSYYJDingZhengBaseUrl, @"StatisticsByQuestion");
    }
    
    
    NSDictionary *dict = @{
                           @"classIds":classids,
                           @"studentIds":studentIds,
                           @"templateId":templateId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        //SYCorrectLogModel
        NSMutableArray *dataArr = [NSMutableArray array];
        NSArray *datalistArr = responseObject[@"data"];
        
        for (NSDictionary *dic in datalistArr) {
            SYStatisticsByQuestion *questionModel = [SYStatisticsByQuestion yy_modelWithDictionary:dic];
            [dataArr addObject:questionModel];
        }
        
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
    
    
}
//按照学生统计
+ (void)yj_requestStatisticsServiceByStudentsClassIds:(NSString *)classids
                                           studentIds:(NSString *)studentIds
                                           templateId:(NSString *)templateId
                                    kaoshiOrDingzheng:(BOOL)isksordz
                                              andSort:(NSString *)sort
                                              success:(void(^)(NSMutableArray *dataListArr))success
                                                 fail:(FailBlock)fail
{
   
    
    NSString *url = nil;
    if (isksordz== YES) {//考试统计
        url = SYStringWithPickFormat(kSYYJTongJiBaseUrl, @"StatisticsByStudent");
        
        
    } else {//订正统计
        url = SYStringWithPickFormat(kSYYJDingZhengBaseUrl, @"StatisticsByStudent");
    }
    
    
    NSDictionary *dict = @{
                           @"sort":sort,
                           @"classIds":classids,
                           @"studentIds":studentIds,
                           @"templateId":templateId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        //SYCorrectLogModel
        NSMutableArray *dataArr = [NSMutableArray array];
        NSArray *datalistArr = responseObject[@"data"];
        
        for (NSDictionary *dic in datalistArr) {
            SYStatisticsByStudent *questionModel = [SYStatisticsByStudent yy_modelWithDictionary:dic];
            [dataArr addObject:questionModel];
        }
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//做题详情
+ (void)yj_requeststatisticsAnswerdQuestionDetailTemplateQuestionId:(NSString *)templateQuestionId
                                                         studentsId:(NSString *)studentsId
                                                  kaoshiOrDingzheng:(BOOL)isksordz
                                                            success:(void(^)(NSMutableArray *dataListArr))success
                                                               fail:(FailBlock)fail
{
    
    NSString *url = nil;
    if (isksordz== YES) {//考试统计
        url = SYStringWithPickFormat(kSYYJTongJiBaseUrl, @"AnsweredQuestionDetail");
        
        
    } else {//订正统计
        url = SYStringWithPickFormat(kSYYJDingZhengBaseUrl, @"AnsweredQuestionDetail");
    }
    
    
    NSDictionary *dict = @{
                           @"templateQuestionId":templateQuestionId,
                           @"studentsIds":studentsId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        //SYCorrectLogModel
        NSMutableArray *dataArr = [NSMutableArray array];
        NSDictionary *dataDict = responseObject[@"data"];
        SYAnsweredQuestionDetail *questionDetail = [SYAnsweredQuestionDetail yy_modelWithDictionary:dataDict];
        //TOP
        questionDetail.dataStudentsArr = [NSMutableArray array];

            NSArray *studentsArr = dataDict[@"dataStudents"];
            for (NSDictionary *studentsDict in studentsArr) {
                SYStudentsModel *studentsModel = [SYStudentsModel yy_modelWithDictionary:studentsDict];
                [questionDetail.dataStudentsArr addObject:studentsModel];
            }
        
        [dataArr addObject:questionDetail];
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
//做卷详情
+ (void)yj_requeststatisticsAnsweredPaperDetailStudentId:(NSString *)studentId
                                              templateId:(NSString *)templateId
                                       kaoshiOrDingzheng:(BOOL)isksordz
                                                 success:(void(^)(NSMutableArray *papeFilePath))success
                                                    fail:(FailBlock)fail
{
    NSString *url = nil;
    if (isksordz== YES) {//考试统计
        url = SYStringWithPickFormat(kSYYJTongJiBaseUrl, @"AnsweredPaperDetail");
        
        
    } else {//订正统计
        url = SYStringWithPickFormat(kSYYJDingZhengBaseUrl, @"AnsweredPaperDetail");
    }
    
    
    NSDictionary *dict = @{
                           @"templateId":templateId,
                           @"studentId":studentId,
                           @"paperPage":@"0"
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        NSArray *dataArr = responseObject[@"data"];
        NSMutableArray *dataListArr = [NSMutableArray array];
        for (NSDictionary *dic in dataArr) {
            NSString *imagePath = [dic nilObjectForKey:@"ImagePath"];
            imagePath = [imagePath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            if (imagePath.length > 0) {
                [dataListArr addObject:imagePath];
            }
        }
        if (success) {
            success(dataListArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}


+ (void)yj_requestStatisticsServicePaperDetailTemplateId:(NSString *)templateId
                                                 success:(void(^)(NSMutableArray *dataListArr))success
                                                    fail:(FailBlock)fail;
{
    
    NSString *url = SYStringWithPickFormat(kSYYJTongJiBaseUrl, @"PaperDetail");
    
    NSDictionary *dict = @{
                           @"templateId":templateId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        //SYCorrectLogModel
        NSMutableArray *dataArr = [NSMutableArray array];
        NSArray *data = responseObject[@"data"];
        for (NSDictionary *dict in data) {
            SYPaperDetailModel *detailModel = [SYPaperDetailModel yy_modelWithDictionary:dict];
                detailModel.subQuestionsArr = [NSMutableArray array];
                NSArray *questions = dict[@"dataSubQuestions"];
                for (NSDictionary *questionDict in questions) {
                    SYDataSubQuestionsModel *questionsModel = [SYDataSubQuestionsModel yy_modelWithDictionary:questionDict];
                    [detailModel.subQuestionsArr addObject:questionsModel];
                }
            [dataArr addObject:detailModel];
        }
        
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
    
    
}
//作业统计
+ (void)yj_requestStatisticsZuoyYeByQuestionClassIds:(NSString *)classids
                                           studentIds:(NSString *)studentIds
                                           templateId:(NSString *)templateId
                                    kaoshiOrDingzheng:(BOOL)isksordz
                                              success:(void(^)(NSMutableArray *dataListArr))success
                                                 fail:(FailBlock)fail
{
    NSString *url = nil;
    NSDictionary *dict;
    if (isksordz== YES) {//考试统计
        url = SYStringWithPickFormat(kSYYJTongJiBaseUrl, @"StatisticsByQuestion");
        
        dict = @{
                 @"classIds":classids,
                 @"studentIds":studentIds,
                 @"templateId":templateId
                 };
        
        
    } else {//作业统计
        url = SYStringWithPickFormat(kSYZYTongJiBaseUrl, @"PaperSubmitInfo");
        dict = @{
                 @"classId":classids,
                 @"pageIndex":@"1",
                 @"pageSize":@"300",
                 @"templateId":templateId
                 };
    }
    
    
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        //SYCorrectLogModel
        NSMutableArray *dataArr = [NSMutableArray array];
        NSArray *datalistArr = responseObject[@"data"];
        
        for (NSDictionary *dic in datalistArr) {
            SYKaoPingZYModel *questionModel = [SYKaoPingZYModel yy_modelWithDictionary:dic];
            [dataArr addObject:questionModel];
        }
        
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
    
    
}


//做卷详情
+ (void)yj_requeststatisticsZuoYePaperDetailStudentId:(NSString *)studentId
                                              templateId:(NSString *)templateId
                                       kaoshiOrDingzheng:(BOOL)isksordz
                                                 success:(void(^)(NSMutableArray *papeFilePath))success
                                                    fail:(FailBlock)fail
{
    NSString *url = nil;
    if (isksordz== YES) {//考试统计
        url = SYStringWithPickFormat(kSYZYTongJiBaseUrl, @"AnsweredPaperDetail");
        
        
    } else {//订正统计
        url = SYStringWithPickFormat(kSYZYTongJiBaseUrl, @"StudentPaperFileInfo");
    }
    
    
    NSDictionary *dict = @{
                           @"templateId":templateId,
                           @"studentId":studentId,
                           @"paperPage":@"0"
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        
        NSArray *dataArr = responseObject[@"data"];
        NSMutableArray *dataListArr = [NSMutableArray array];
        for (NSDictionary *dic in dataArr) {
            NSString *imagePath = [dic nilObjectForKey:@"ImagePath"];
            imagePath = [imagePath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
            if (imagePath.length > 0) {
                [dataListArr addObject:imagePath];
            }
        }
        if (success) {
            success(dataListArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}

//修改过后的考试信息
+ (void)yj_requestNewStatisticsServiceEXamInfoTemplateId:(NSString *)templateId WithClassId:(NSString *)classId
                                              success:(void(^)(NSMutableArray *dataListArr))success
                                                 fail:(FailBlock)fail
{
    NSString *url = SYStringWithPickFormat(kSYYJTongJiBaseUrl, @"ExamInfo");
    
    NSDictionary *dict = @{
                           @"templateId":templateId,
                           @"classId":classId
                           };
    
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        //SYCorrectLogModel
        NSMutableArray *dataArr = [NSMutableArray array];
        NSDictionary *dic = responseObject[@"data"];
        SYExamInfoModel *logModel = [SYExamInfoModel yy_modelWithDictionary:dic];
        logModel.dataClassesArr = [NSMutableArray array];
        NSArray *dataClassesArr = dic[@"dataClasses"];//班级
        NSInteger index = 0;
        for (NSDictionary *classesDict in dataClassesArr) {
            SYExamInfoClassesModel *classesModel = [SYExamInfoClassesModel yy_modelWithDictionary:classesDict];
            if (index == 0) {//默认第一个选中
                classesModel.isSelect = YES;
            } else {
                classesModel.isSelect = NO;
            }
            index ++;
            classesModel.newisSelect = NO;
            classesModel.dataStudentsArr = [NSMutableArray array];//学生
            NSArray *studentsArr = classesDict[@"dataClassesStudents"];
            for (NSDictionary *studentsDict in studentsArr) {
                SYExamInfoStudentsModel *studentsModel = [SYExamInfoStudentsModel yy_modelWithDictionary:studentsDict];
                studentsModel.isSelect = YES;
                studentsModel.newisSelect = YES;
                [classesModel.dataStudentsArr addObject:studentsModel];
            }
            
            [logModel.dataClassesArr addObject:classesModel];
        }
        [dataArr addObject:logModel];
        
        
        if (success) {
            success(dataArr);
        }
        
    } fail:^(NSError *error) {
        if (error) {
            fail(error);
        }
    }];
}
/// 知识点统计
/// @param scheduleId 补课ID，上一级列表返回的字段
/// @param templateId 模板IDID
/// @param classId 班级ID
/// @param sort 排序
/// @param success 0
/// @param fail 1
+ (void)tj_requestStatisticsServiceByKnowledgeScheduleId:(NSString *)scheduleId
                                              templateId:(NSString *)templateId
                                                 classId:(NSString *)classId
                                                    sort:(NSString *)sort
                                                 success:(void(^)(NSMutableArray *dataListArr))success
                                                    fail:(FailBlock)fail
{
    NSString *url = @"paper/StatisticsService.svc/StatisticsByKnowledge";
    NSDictionary *dict = @{@"scheduleId":scheduleId,
                           @"templateId":templateId,
                           @"classId":classId,
                           @"sort":sort
    };
    [SYRequestAPI postDataFromURLScheme:url parameterDictionary:dict success:^(id responseObject) {
        NSMutableArray *datalistArr = responseObject[@"data"];
        if (success) {
            success(datalistArr);
        }
    } fail:^(NSError *error) {
        if (fail) {
            fail(error);
        }
    }];
}
@end





























